package models

import (
	"github.com/jinzhu/gorm"
	"strconv"
)

type DemoOrder struct {
	gorm.Model
	OrderNo  string  `gorm:"not null;unique" form:"order_no"`
	UserName string  `gorm:"not null;unique" form:"user_name"`
	Amount   float64 `gorm:"type:DECIMAL(10,2);not null" form:"amount"`
	Status   string  `gorm:"not null" form:"status"`
	FileUrl  string  `gorm:"size:255" form:"file_url"`
}

//重写String方法
func (o DemoOrder) String() string {
	return "(OrderNo:" + o.OrderNo + " -UserName:" + o.UserName +
		" -Amount:" + strconv.FormatFloat(o.Amount, 'f', -1, 64) +
		" -Status:" + o.Status +
		" -FileUrl:" + o.FileUrl
}
